home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
scrnsav2.zip
/
SCRNSAV2.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-09-01
|
27KB
|
735 lines
page ,132
title scrnsav2 : Screen Saver for PS/2
;
; Copyright (c) 1988 Alan Ballard
;
; This program is a TSR (Terminate and Stay Resident) utility
; "screen saver". It turns off the video after a specified period
; of inactivity (no keyboard or mouse action). Touching the keyboard or
; the mouse will reactivate the screen.
;
; A VGA monitor and the PS/2 extended bios are required.
;
; The program stays resident only the first time it is run. It may be reexecuted
; to disable blanking or to change the interval.
;
; Options are:
; integer - blanking time in minutes (default 5 minutes)
; \d - disable blanking
; \e - enable blanking (default)
; \m integer - set the "multiplex number" to use for communicating
; with the loaded version.
;
; Interrupt numbers
Keyboard@ equ 09h
Video_Io@ equ 10h
System_Services@ equ 15h
Timer@ equ 1ch
Dos@ equ 21h
Multiplex@ equ 2fh
Mouse@ equ 74h
; Video I/O function numbers
Read_Display_Combination_Code equ 1a00h
; System services function numbers
Keyboard_Intercept equ 4fh
; Multiplex function numbers
Get_Installed_State equ 0
; Scrnsav2 multiplex functions
Scrnsav_Multiplex_Number equ 150 ; random choice
Scrnsav_Disable equ 10h
Scrnsav_Enable equ 11h
Scrnsav_Set_Interval equ 12h
; DOS function numbers
Print_String equ 09h
Print_Char equ 02h
Set_Int equ 25h
Get_Int equ 35h
TSR equ 31h
Terminate equ 4ch
; Miscellaneous constants
Ticks_Per_Minute equ 1092 ; 60*18.2
Default_Time equ 5 ; five minute default
Max_Time equ 30 ; 30 minute maximum (30*1092=32760)
Cr equ 0dh
Lf equ 0ah
True equ 0ffh
False equ 00h
; VGA adaptor constants
SAR equ 03c4h ; Sequencer Address Register
SDR equ 03c5h ; Sequencer Data Register
Clocking_Mode_Index equ 01 ; SAR index for clocking mode reg
Screen_Mask equ 20h ; Mask for screen off bit.
Scrnsav2 segment para 'code'
assume cs:Scrnsav2,ds:nothing,es:nothing
;
; Overlay permanent data on PSP.
;
org 05ch ; not supposed to change anything before this
Old_Mouse dd ? ; save old int 74 (mouse)
Old_Timer dd ? ; save old timer tick
Old_Ss dd ? ; save old system services
Old_Multiplex dd ? ; save old multiplex
;
Idle_Count dw ? ; Ticks till we shutdown
Idle_Max dw ? ; Initial ticks
Save_Reg db ? ; Place to save CRT register value
Multiplex_No db ? ; Multiplex number we're using
Disabled db ? ; enable/disable flag
;
; Define command line in PSP...
;
org 080h
Cmdline label byte
page
; Code starts at offset 0100h for COM file.
org 0100h ; beginning for .com programs
Start: jmp Initialize ; initialization code is at end.
;
; int 15 (system services) enters here. Checks for keyboard intercept
; which shows some activity. Passed on to old interrupt routine in all
; cases.
;
System_Services proc far
cmp ah,Keyboard_Intercept
jne NotKey
call Action ; record something happenned
NotKey: jmp Old_Ss ; pass it on to old routine
System_Services endp
;
; int 74h (mouse) enters here. This also shows there is user activity.
;
Mouse proc far
call Action ; record something happenned
jmp Old_Mouse ; pass it on
Mouse endp
;
; Common processing for keyboard and mouse action.
; Reset timeout interval; turn screen back on if it was off.
;
Action proc near
push ax ; save a register
cmp Idle_Count,0 ; have we reached zero
jne Reset ; no, just reset count
; Count had reached zero, so we would have disabled the screen.
; Need to turn it back on here.
push dx
mov dx,SAR ; Get the current SDR index
in al,dx ; ... value and save it
push ax ; ...
mov al,Clocking_Mode_Index ; Then point it to clocking mode
out dx,al ; ... register.
mov dx,SDR ; Set the clocking mode register
mov al,Save_Reg ; ... back to what it was
out dx,al
mov dx,SAR ; Reset SAR to what it was
pop ax ; ...
out dx,al ; ...
pop dx
Reset: mov ax,Idle_Max ; reset count to max
mov Idle_Count,ax ; ...
pop ax ; restore
ret ; return
Action endp
;
; int 1ch (timer tick) enters here. If blanking enabled, decrement count
; and see if time to blank screen.
;
Timer proc far
cmp Disabled,True ; are we active?
je Done ; no, quit
cmp Idle_Count,0 ; already turned off?
je Done ; ok, nothing to do
dec Idle_Count ; subtract one...
jnz Done ; quit if still nonzero
; Count has reached zero. Turn off the display.
push dx
push ax
mov dx,SAR ; Get the current SDR index
in al,dx ; ... value and save it
push ax ; ...
mov al,Clocking_Mode_Index ; Then point it to clocking mode
out dx,al ; ... register.
mov dx,SDR ; Get the clocking mode register
in al,dx ; ...
mov Save_Reg,al ; Save it away for later
or al,Screen_Mask ; set the video off bit
out dx,al ; ...
mov dx,SAR ; Reset SAR to what it was
pop ax ; ...
out dx,al ; ...
pop ax
pop dx
Done: jmp Old_Timer ; continue with other int routine.
Timer endp
page
;
; int 2fh (Multiplex) enters here. This is used for communication from
; later runs of Scrnsav2 program.
;
Multiplex proc far
cmp ah,Multiplex_No ; is this our number?
je Mine ; yes,...
jmp Old_Multiplex ; no, pass it on.
Mine: cmp al,Get_Installed_State ; are we just testing?
jne Mine2 ; work to do
; Set result to indicate installed. Also, pass back our name as further
; check for someone else using the number.
mov al,0ffh ; code to say we're here
push ds ; copy ds to es
pop es ; ...
lea di,es:Scrnsav_Str ; offset for our name
iret ; return it to caller.
; Look for other function requests
Mine2: cmp al,Scrnsav_Enable
jne Mine3
mov Disabled,False ; set enabled
jmp Valid
Mine3: cmp al,Scrnsav_Disable
jne Mine4
mov Disabled,True ; set disabled
jmp Valid
Mine4: cmp al,Scrnsav_Set_Interval
jne Invalid
mov Idle_Max,bx ; reset interval
Valid: mov al,0 ; set success code
iret
Invalid: mov al,1 ; r